package com.risk.web.controller.tk;

import com.risk.common.core.controller.BaseController;
import com.risk.common.core.domain.AjaxResult;
import com.risk.common.core.page.TableDataInfo;
import com.risk.kernel.domain.TkTaskCaseInfo;
import com.risk.kernel.service.TkTaskCaseInfoServiceI;
import com.risk.kernel.vo.TkTaskCaseInfoVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author: Liwen
 * @createTime: 2025/1/7
 * @description:
 */
@RestController
@RequestMapping("/tk/task/case/info")
public class TkTaskCaseInfoController extends BaseController {
    @Autowired
    private TkTaskCaseInfoServiceI tkTaskCaseInfoService;

    /**
     * 查询列表
     */
    @PreAuthorize("@ss.hasPermi('tk:case:info:list')")
    @GetMapping("/list/{caseId}")
    public TableDataInfo list(@PathVariable String caseId) {
        startPage();
        List<TkTaskCaseInfoVo> list = tkTaskCaseInfoService.selectTkTaskCaseInfoList(caseId);
        return getDataTable(list);
    }


    /**
     * 获取
     */
    @PreAuthorize("@ss.hasPermi('tk:case:info:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id) {
        return success(tkTaskCaseInfoService.selectTkTaskCaseInfoById(id));
    }

    /**
     * 新增
     */
    @PreAuthorize("@ss.hasPermi('tk:case:info:add')")
    @PostMapping
    public AjaxResult add(@RequestBody TkTaskCaseInfo tkTaskCaseInfo) {
        return toAjax(tkTaskCaseInfoService.insertTkTaskCaseInfo(tkTaskCaseInfo));
    }

    /**
     * 修改
     */
    @PreAuthorize("@ss.hasPermi('tk:case:info:edit')")
    @PutMapping(value = "edit")
    public AjaxResult edit(@RequestBody TkTaskCaseInfoVo infoVo) {

        return toAjax(tkTaskCaseInfoService.updateTkTaskCaseInfo(infoVo));

    }

    /**
     * 删除
     */
    @PreAuthorize("@ss.hasPermi('tk:case:info:remove')")
    @DeleteMapping("/remove/{ids}")
    public AjaxResult remove(@PathVariable String[] ids) {
        return toAjax(tkTaskCaseInfoService.deleteTkTaskCaseInfoByIds(ids));
    }
}
